import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
import pylab as pl

plt.plot([1, 2, 3, 10])
plt.xlabel("x-axis")
plt.ylabel("my numbers")
plt.title("my figuer")
plt.show()


x = np.linspace(-np.pi, np.pi, 256, endpoint = True)
C,S = np.cos(x),np.sin(x)
pl.plot(x, C), pl.plot(x, S)
pl.show()

n= 1024
X = np.random.normal(0, 1, n)
Y = np.random.normal(0, 1, n)
pl.scatter(X, Y)
pl.show()

pv = 1000
r = 0.08
n = 10
t = pl.linspace(0, n, n)
y1 = np.ones(len(t)) * pv #this is a horizontal line
y2 = pv * (1 + r * t)
y3 = pv * (1 + r) ** t
pl.title('Simple vs. Compounded interest rates')
pl.xlabel('number of years')
pl.ylabel('Values')
pl.xlim(0, 11)
pl.ylim(800, 2000)
pl.plot(t, y1, 'b-')
pl.plot(t, y2, 'g--')
pl.plot(t, y3, 'r-')
pl.show()

x4 = [0, 1, 2]
y4 = [2, 4, 6]
pl.plot(x4, y4)
pl.figtext(0.2, 0.7, 'North & West')
pl.figtext(0.7, 0.2, 'South & East')
pl.show()

ind = np.arange(3)
plt.title('DuPont Identity')
plt.xlabel('Different companies')
plt.ylabel('Three Ratios')
ROE = [0.88, 0.22, 0.22]
a = [0.16, 0.04, 0.036]
b = [0.88, 1.12, 2.31]
c = [6.32, 4.45, 2.66]
width = 0.45
plt.figtext(0.2, 0.85, 'ROE = 0.88')
plt.figtext(0.5, 0.7, 'ROE = 0.22')
plt.figtext(0.8, 0.6, 'ROE = 0.22')
plt.figtext(0.2, 0.75, 'Profit Margin = 0.16')
plt.figtext(0.5, 0.5, '0.041')
plt.figtext(0.8, 0.4, '0.036')
p1 = plt.bar(ind, a, width, color = 'b')
p2 = plt.bar(ind, b, width, color = 'r', bottom = a)
index_a = range(2)
for j in index_a: 
    bottom_aAndb = a[j] + b[j] 
    p3: object = plt.bar(ind, c, width, color = 'y', bottom = bottom_aAndb)
plt.xticks(ind + width / 2., ('IBM', 'DELL', 'WMT'))
plt.show()

cashflows = [-100, 50, 60, 70]
rate = []
npv = []
x = (0, 0.7)
y = (0, 0)
for i in range(0, 70):
    rate.append(0.01 * i)
    npv.append(sp.npv(0.01 * i, cashflows[1 :]) + cashflows[0])
plt.show()